<meta charset="UTF-8">
<div class="mcy_body">
	<div id="home">
		<ul class="breadcrumb">
			<li><span class="glyphicon glyphicon-home"></span>&emsp;当前位置：</li>
			<li class="active">我的博客</li>
		</ul>
		<p style="font-size: 20px; margin-bottom: 10px; margin-left: 10px;">
			<span th:text="${user.nickname}"></span>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;    
			博客总数：<span th:text="${user.blogSize}"></span>
		</p>
		<ul class="flow-default" id="LAY_demo1"></ul>
	</div>
</div>

<script type="text/javascript">
layui.use('flow', function(){
	  var flow = layui.flow;
	 
	  flow.load({
	    elem: '#LAY_demo1' //流加载容器
	    ,scrollElem: '#LAY_demo1' //滚动条所在元素，一般不用填，此处只是演示需要。
	    ,done: function(page, next){ //执行下一页的回调
	      
	      //模拟数据插入
	      setTimeout(function(){
	        var lis = [];
	        $.post('blog/fysj',{page:page},function(res){
	        		 layui.each(res.data, function(index, item){
	 	                lis.push("<div class='list-group'><a href='#' class='list-group-item' onclick='details("+item.id+")'>"+
	 	                		"<h4 class='list-group-item-heading'>"+item.title+"</h4><p class='list-group-item-text'>"
	 	                		+item.user.nickname+"   |   "+item.updateDate+"   |  &nbsp;&nbsp;&nbsp;状态："+item.blogStatic+
	 	                		"</p></a>"+
	 	                		"<span id='remove' title='删除' onclick='del("+item.id+")' style='float: right; top: -32px; margin-right: 20px;' data-toggle='tooltip' data-placement='left' class='glyphicon glyphicon-remove'></span>"+
	 	                		"<span id='remove' title='编辑' onclick='edit("+item.id+")' style='float: right;margin-right: 15px; top: -32px;' data-toggle='tooltip' data-placement='left' class='glyphicon glyphicon-pencil'></span>"+
	 	                		"</div>");
	 	              }); 	   	       
	        next(lis.join(''), page < res.pages); //假设总页数为 10
	        $('[data-toggle="tooltip"]').tooltip()
	        });  
	        //执行下一页渲染，第二参数为：满足“加载更多”的条件，即后面仍有分页
	        //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
	      });
	    }
	  });
	  
	});
	
	function edit(id){
		$("#main").load("blog/edit?id="+id);
	}
	function del(id){
		layui.use('layer', function(){
			var layer = layui.layer;
			layer.confirm('确定要删除吗？', function(index) {
				$.post("blog/delete?id="+id, function(data){
					layer.msg(data.msg,{offset:'rb'});
					$("#main").load("blog/manage");
				})
			});
		});
	}
	function details(id){
		window.open("blog/visit?id="+id);
	}
</script>

